Skip to content

fix(android): truncated stacktraces in crash daemon events - #2357

Open
jpnurmi wants to merge 6 commits into
jpnurmi/fix/android-os-contextfrom
jpnurmi/fix/native-android-stacktrace
Open

jpnurmi wants to merge 6 commits into
jpnurmi/fix/android-os-contextfrom
jpnurmi/fix/native-android-stacktrace

Conversation

@jpnurmi

@jpnurmi jpnurmi commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Required for:

A JNI crash captured by the Native backend in a React Native app showed only the JNI function and an unknown address. The crash daemon preferred the signal handler's frame-pointer capture (#2174) over unwinding with libunwindstack (#1725). The capture skips the caller of a leaf function without a frame record and stops at frames without records, such as ART's.

  • On arm64, the capture records x30 as the first caller.
  • The daemon replaces the capture with a libunwindstack unwind unless on_crash or before_send edited it. on_crash still sees the capture.
Before After
image image

The signal handler records a frame-pointer walk of the crashed thread
because libunwindstack allocates, and `has_captured_stack()` preferred
that walk over unwinding the saved fault context with libunwindstack.

The walk skips the caller of a leaf function without a frame record
and stops at frames without records such as ART's. In a React Native
app, a JNI crash kept only the JNI function and a junk address.

Unwind the saved context first and fall back to the walk if that
fails.
Drop the libunwindstack unwind from the previous commit. It replaced
the stacktrace that `on_crash` had already seen and possibly edited
with a new one. Fix the signal handler's capture instead.

The capture walks frame records from `x29` on arm64. A leaf function
without a frame record leaves its caller only in `x30`, so the walk
skipped it. Record `x30` as the first caller.
The frame-pointer capture stops at frames without records, such as
ART's in a JNI crash. Replace it with the libunwindstack unwind unless
`on_crash` or `before_send` edited it. `on_crash` still sees the
capture.
@jpnurmi
jpnurmi force-pushed the jpnurmi/fix/native-android-stacktrace branch from c90edf8 to 9559965 Compare November 30, 2026 14:57
@jpnurmi
jpnurmi changed the base branch from v1 to jpnurmi/fix/android-os-context November 30, 2026 14:57
@jpnurmi
jpnurmi added this pull request to stack #2358 November 30, 2026 14:58
The crashed app waits for the daemon. Instead of rebuilding and
serializing the captured stacktrace, compare the event's frame
addresses with the capture. This still detects a stacktrace replaced
by `on_crash` or `before_send`, but no longer in-place edits.
Combining `has_captured_stack()` with a negated, similarly named
predicate read poorly.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant